package com.yonyou.crm.sys.quartz.service;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.yonyou.crm.common.biz.service.BaseBizServiceImpl;
import com.yonyou.crm.sys.quartz.common.BeanExtendUtil;
import com.yonyou.crm.sys.quartz.dentity.DispatchTaskLogDO;
import com.yonyou.crm.sys.quartz.ventity.DispatchTaskLogVO;

@Service("DispatchTaskLogBizService")
public class DispatchTaskLogBizService extends
		BaseBizServiceImpl<DispatchTaskLogDO> {
	@SuppressWarnings("unused")
	private final Logger logger = LoggerFactory.getLogger(getClass());

	/**
	 * 保存任务分组
	 * 
	 * @param vo
	 * @return
	 */
	public DispatchTaskLogVO saveTaskLog(DispatchTaskLogVO vo) {
		// vo转换为do进行保存
		DispatchTaskLogDO logDO = new DispatchTaskLogDO();
		BeanExtendUtil.copyProperties(logDO, vo);
		logDO = saveVO(logDO);
		BeanExtendUtil.copyProperties(vo, logDO);
		return vo;
	}

	/**
	 * 更新日志
	 * 
	 * @param vo
	 * @return
	 */
	public DispatchTaskLogVO updateTaskLog(DispatchTaskLogVO vo) {

		// vo转换为do进行保存
		DispatchTaskLogDO logDO = new DispatchTaskLogDO();
		BeanExtendUtil.copyProperties(logDO, vo);
		logDO = super.updateVO(logDO);
		BeanExtendUtil.copyProperties(vo, logDO);
		return vo;
	}

	/**
	 * 删除日志
	 * 
	 * @param id
	 * @return
	 */
	public int deleteTaskLog(String id) {
		Map<String, Object> paramMap = new HashMap<>();
		//	BaseDao 做了修改
//		int n = dao.deleteById(DispatchTaskLogDO.class, id);
		int n = dao.batchDelete(DispatchTaskLogDO.class, id);
		return n;
	}

	public DispatchTaskLogVO getVOById(String id) {
		DispatchTaskLogVO VO = new DispatchTaskLogVO();
		if (super.getVOById(DispatchTaskLogDO.class, id) != null) {
			BeanExtendUtil.copyProperties(VO,
					super.getVOById(DispatchTaskLogDO.class, id));
		}
		return VO;
	}
}
